package com.wangshouyu.plugins.log.config;

import com.wangshouyu.plugins.log.aop.AopRequestLogClassAnnotationAdvisor;
import com.wangshouyu.plugins.log.aop.AopRequestLogInterceptor;
import com.wangshouyu.plugins.log.aop.AopRequestLogMethodAnnotationAdvisor;
import com.wangshouyu.plugins.log.print.LogPrint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 王守钰
 * @description aop请求日志配置
 * @date 2020年7月23日10:36:36
 */
@Configuration
@ConditionalOnProperty(value = "log.plugin.request-support",matchIfMissing = true)
public class AopRequestLogConfiguration extends AbstractLogConfiguration {

    @Bean
    @ConditionalOnMissingClass
    public AopRequestLogInterceptor aopRequestLogInterceptor(LogPrint logPrint){
        AopRequestLogInterceptor aopRequestLogInterceptor = new AopRequestLogInterceptor();
        aopRequestLogInterceptor.setLogPrint(logPrint);
        return aopRequestLogInterceptor;
    }

    @Bean
    @ConditionalOnMissingClass
    public AopRequestLogMethodAnnotationAdvisor aopRequestLogMethodAnnotationAdvisor(AopRequestLogInterceptor aopRequestLogInterceptor){
        return new AopRequestLogMethodAnnotationAdvisor(aopRequestLogInterceptor);
    }

    @Bean
    @ConditionalOnMissingClass
    public AopRequestLogClassAnnotationAdvisor aopRequestLogClassAnnotationAdvisor(AopRequestLogInterceptor aopRequestLogInterceptor){
        return new AopRequestLogClassAnnotationAdvisor(aopRequestLogInterceptor);
    }
}
